--[[ scheme_type: generic author: ??? modified_by: Alundaio --]] class "action_process_hit" function action_process_hit:__init(obj, storage) self.object = obj self.st = storage end function action_process_hit:hit_callback(obj, amount, local_direction, who, bone_index) db.storage[self.object:id()].hit.bone_index = bone_index if amount == 0 and not(obj:invulnerable()) then return end if who then --printf("[%s] hit by [%s]", obj:name(), who:name()) db.storage[obj:id()].hit.who = who:id() else --printf("[%s] hit by [Unknown]", victim:name()) db.storage[obj:id()].hit.who = -1 end if db.storage[self.object:id()].active_scheme then --printf("DEADLY HIT %s %s", amount, self.object.health) db.storage[self.object:id()].hit.deadly_hit = amount >= self.object.health*100 if xr_logic.try_switch_to_another_section(obj, db.storage[self.object:id()].hit, db.actor) then db.storage[self.object:id()].hit.deadly_hit = false return end db.storage[self.object:id()].hit.deadly_hit = false end end ---------------------------------------------------------------------------------------------------------------------- -- binder ---------------------------------------------------------------------------------------------------------------------- function setup_generic_scheme(npc,ini,scheme,section,stype,temp) local hit_section = ini:r_string_ex(section,"on_hit") if (hit_section) then local st = xr_logic.assign_storage_and_bind(npc, ini, "hit", hit_section,temp) st.logic = xr_logic.cfg_get_switch_conditions(ini, hit_section, npc) end end function add_to_binder(npc,ini,scheme,section,st,temp) st.action = action_process_hit(npc,st) xr_logic.subscribe_action_for_events(npc, st, st.action) end function disable_generic_scheme(npc,scheme,stype) local st = db.storage[npc:id()][scheme] if st then xr_logic.unsubscribe_action_from_events(npc, st, st.action) end end